<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <link rel="stylesheet" type="text/css" href="/stylesheets/index.css" />
    <link rel="stylesheet" type="text/css" href="/stylesheets/user.css" />
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
        #mask{
            height: 1000px;
            width: 100%;
            background: lightgrey;
            position: absolute;
            opacity: 0.3;
            z-index: 999;
            display: none;
        }
        .edit{
            background: #fff;
            position: absolute;
            z-index: 1000;
            width: 600px;
            left: 50%;
            margin-left: -300px;
            display: none;
        }
        #close{
            background: url("/images/sys_td_btn_3.gif");
            width: 18px;
            height: 18px;
            cursor: pointer;
            float: right;
        }
    </style>
</head>
<body>
    <div class="sys_contnt">
        <div class="sys_content_left">
            <ul>
                <li class="sys_content_left_l1"><a href="/user_list" id="groupmanager">用户管理</a></li>
                <li ><a id="useradd" href="/user_add">用户添加</a></li>
            </ul>
        </div>
        <div class="sys_content_right" >
            <div class="sys_user">
                <h1 class="fleft">用户管理</h1>
                <form action="/searchuser" method="post">
                    <input type="submit" class="s_sub" value="搜 索"/>
                    <input type="text" class="search" name="searchcontent" placeholder="请输入用户名或真实姓名"/>
                </form>
                <table cellpadding="0" border="0" cellspacing="0" class="user clear">
                    <tr class="first">
                        <td width="5%"></td>
                        <td width="8%">用户名</td>
                        <td width="10%">密码</td>
                        <td width="5%">登录ip</td>
                        <td width="10%">用户编码</td>
                        <td width="40%">用户描述</td>
                        <td width="10%">最后登录时间</td>
                        <td width="10%">操作</td>
                    </tr>
                    <%for(var i = 0; i < userlist.length; i++){%>
                    <%if(i%2 == 0){%>
                    <tr >
                        <td><input type="checkbox" class="checkbox" title="<%= userlist[i]["userId"]%>" /></td>
                        <td width="5%"><%= userlist[i]["userName"]%></td>
                        <td width="5%"><%= userlist[i]["pwd"]%></td>
                        <td width="8%">localhost</td>
                        <td width="10%"><%= userlist[i]["userCode"]%></td>
                        <td width="10%"><%= userlist[i]["description"]%></td>
                        <td width="40%"><%= userlist[i]["createTime"]%></td>
                        <td>
                            <ul class="user_table_edit w84">
                                <li><a  class="user_edit"  href="" ></a></li>
                                <li><input type="button" class="user_pwd" onclick="editUser(<%=JSON.stringify(userlist[i])%>)"></li>
                                <li><input type="button" class="user_del" onclick="deletUser(<%=userlist[i]["userId"]%>)"></li>
                            </ul>
                        </td>
                    </tr>
                    <%}else{%>
                    <tr class="double">
                        <td><input type="checkbox" class="checkbox" title="<%= userlist[i]["userId"]%>" /></td>
                        <td width="5%"><%= userlist[i]["userName"]%></td>
                        <td width="5%"><%= userlist[i]["pwd"]%></td>
                        <td width="8%">localhost</td>
                        <td width="10%"><%= userlist[i]["userCode"]%></td>
                        <td width="10%"><%= userlist[i]["description"]%></td>
                        <td width="40%"><%= userlist[i]["createTime"]%></td>
                        <td>
                            <ul class="user_table_edit w84">
                                <li><a  class="user_edit"  href="" ></a></li>
                                <li><input type="button" class="user_pwd" onclick="editUser(<%=JSON.stringify(userlist[i])%>)"></li>
                                <li><input type="button" class="user_del" onclick="deletUser(<%=userlist[i]["userId"]%>)"></li>
                            </ul>
                        </td>
                    </tr>
                    <%}%>

                    <%}%>
                </table>
                <div class="div_page2">
                    <span class="w5"><input type="checkbox" class="check_all" id="selectall"/></span>
                    <span><a href="##" class="btn_del" id="batchdel">删 除</a></span>

                    <ul class="change" id="pagelist">
                        
                        
                       
                        <li class="pageChange"><a href="" onclick="" >下一页</a></li>
                        

                        <li class="page"><a href="">1</a></li>
                       
                        <li class="pageChange"><a href="">上一页</a></li>
                        
                        
                    </ul>
                </div>
                <div class="clear"></div>
            </div>
        </div>
    </div>
<div id="mask">

</div>
    <div class="edit" id="edituser">
        <div class="user_add">
            <h1>修改用户<input type="button" id="close" class="user_del"></h1>
            <div class="con">
                <form action="/edituser" method="post">
                    <table cellpadding="0" border="0" cellspacing="0" class="d">
                        <tr>
                            <td width="20%" class="td_1">用户名：</td>
                            <td width="80%"><input type="text" name="username" class="text" id="username"/></td>
                        </tr>
                        <tr>
                            <td width="20%" class="td_1">工<img src="images/word.png" alt=""/>号：</td>
                            <td width="80%"><input type="text" name="usercode" class="text" id="usercode"/></td>
                        </tr>
                        <tr>
                            <td class="td_1">用户组：</td>
                            <td>
                                <div id="s1" class="select">
                                    <span>搜索</span>
                                    <ul>

                                    </ul>
                                    <input type="hidden" name="usergroup" id="usergroup"/>
                                </div>
                            </td>
                        </tr>
                        <tr>
                            <td class="td_1">机<img src="images/word.png" alt=""/>构：</td>
                            <td>
                                <div id="s2" class="select">
                                    <span>搜索</span>
                                    <ul>
                                    </ul>
                                    <input type="hidden" name="userdepart" id="userdepart"/>
                                </div>
                            </td>
                        </tr>
                        <tr>
                            <td class="td_1">密<img src="images/word.png" alt=""/>码：</td>
                            <td><input type="password" name="pwd" id="pwd" class="text"/>
                                <input name="button" type="submit" class="passbut" id="button" value="随机密码" /></td>
                        </tr>
                        <tr class="tr_5">
                            <td class="td_1"><span class="td_t">备<img src="images/word.png" alt=""/>注：</span></td>
                            <td class="texta"><textarea rows="8" cols="34" name="description" id="description"></textarea></td>
                        </tr>
                        <tr>
                            <td>
                                <input type="hidden" name="userId" id="userId">
                            </td>
                            <td class="td_btn"><input type="submit" class="btn_sub" id="btn"  value="提 交"/></td>
                        </tr>
                    </table>
                </form>
            </div>
        </div>
    </div>
</body>
<script type="text/javascript" src="/javascripts/jquery-3.2.1.min.js"></script>
<script type="text/javascript" src="/javascripts/main.js"></script>
<script type="text/javascript" src="/routes/users.js"></script>
<script>
    function editUser(department) {
        $("#mask").css("display","block");
        window.parent.document.getElementById("mask").style.display="block";
        $("#edituser").css("display","block");
        $("#username").val(department["userName"]);
        $("#pwd").val(department["pwd"]);
        $("#usercode").val(department["userCode"]);
        $("#description").val(department["description"]);
        $("#userId").val(department["userId"]);
    }
    $("#close").click(function () {
        $("#mask").css("display","none");
        window.parent.document.getElementById("mask").style.display="none";
        $("#edituser").css("display","none");
    })
    $("#btn").click(function () {
        $("#editform").submit();
        $("#mask").css("display","none");
        window.parent.document.getElementById("mask").style.display="none";
        $("#edituser").css("display","none");
    });
    function deletUser(userId) {
        if (confirm("确认删除该条数据")){
            $.post("/deuser",{userId:userId},function (data) {
                alert(data);
                window.history.go(0);
            })
        }
    }
    $("#batchdel").click(function () {
        var choosee=[];
        $(":checked").each(function () {
            choosee.push($(this).attr("title"));
        })
        $.ajax({
            url:"/delete",
            data:{choosee:choosee.toString()},
            type:"post",
            success:function (data) {
                alert(data);
                window .history.go(0);
            },
            error:function (err) {
                console.log(err);
            }
        })
    });

</script>
</html>